import os
import os.path
import json

#打开两个文件
name_list = []
id_list = []
with open("name.txt","r",encoding="utf-8") as f:
    for line in f.readlines():
        name_list.append(line.strip())
with open("id.txt","r",encoding="utf-8") as f:
    for line in f.readlines():
        id_list.append(line.strip())
id_name_dict = {}
for i in range(len(name_list)):
    id_name_dict[id_list[i]] = name_list[i]

with open("id_name.json","w",encoding="utf-8") as f:
    json.dump(id_name_dict,f,ensure_ascii=False)
print(id_name_dict)